package com.yanu.trace.t2s.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yanu.trace.t2s.entity.Pig;
import com.yanu.trace.t2s.mapper.PigMapper;
import com.yanu.trace.t2s.service.PigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whj
 * @since 2021-06-23
 */
@Service
@Transactional
public class PigServiceImpl extends ServiceImpl<PigMapper, Pig> implements PigService {
    @Autowired
    PigMapper pigMapper;

    /**
     * 根据企业id查询该企业所有的猪并分页返回
     * @param page
     * @param eid
     * @return
     */
    @Override
    public IPage<Pig> selectPage(Page<?> page,Integer eid) {
        return pigMapper.selectPageVoByeid(page,eid);//调用Mapper内的函数根据企业id进行分页
    }

    /**
     * 根据猪id联立pig和enterprise表返回一个带企业信息的pig实体
     * @param id
     * @return
     */
    @Override
    public Pig selectByidpae(Integer id) {
        return pigMapper.selectByidpae(id);
    }

    /**
     * 查询所有猪
     * @param page
     * @return
     */
    @Override
    public IPage<Pig> selectPageAll(Page<?> page) {
        return pigMapper.selectPageVoAll(page);
    }
}
